/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#ifndef __LIB3D_COLOREVENT_H__
#define __LIB3D_COLOREVENT_H__

#include <xml/Object.h>
#include <xml/Stream.h>
#include "../ParticleEvent.h"

namespace liba
{
	namespace lib3d
	{
		namespace particles
		{
			class ColorEvent : public ParticleEvent
			{
			private:
				struct ColorRandom
				{
					Color value;
					Color random;
				};
			private:
				Float _time;
				bool  _relative;
				Color _color;
				bool  _randomUsed;
				Color _randomMin;
				Color _randomMax;
			private:
				virtual ~ColorEvent();
				Color get_color_for_particle(Particle * particle, KeyFrameIterator base_frame, KeyFrameArray * frames);
				ColorRandom * get_random_for_particle(Particle * particle);
			public:
				ColorEvent();
				void set_color(const Color & value);
				Color get_color();
				void set_time(float value);
				virtual void update_particle(Particle * particle, Float delta_time, KeyFrameIterator base_frame, KeyFrameIterator next_frame, KeyFrameArray * frames);
				virtual Atom get_type();
				virtual Float get_time();
				virtual bool on_attribute(xml::Provider * provider, const std::string & name, const std::string & value);
				virtual void on_save_attributes(xml::SaverBase * saver) const;
			};
		}
	}
}

#endif